// 定义resolve方法，用于配置路径别名
const path = require("path");
function resolve(dir) {
  return path.join(__dirname, dir);
}

module.exports = {
  devServer: {
    // host: 'localhost', // can be overwritten by process.env.HOST
    // port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
    proxy: {
      "/hls": {
        target: "http://192.168.2.33:8765", // 目标服务器地址，每次修改地址需要重新编译项目
        changOrigin: true, // 跨域
        ws: true, // 是否代理websockets
        pathRewrite: {
          "^/hls": "" // 重写请求
        }
      }
    }
  },
  productionSourceMap: false,
  // 链式操作内部配置
  chainWebpack: config => {
    // 移除 prefetch 插件
    config.plugins.delete("prefetch");
  },
  configureWebpack: {
    resolve: {
      alias: {
        "@": resolve("src"),
        "#": resolve("public"),
        img: resolve("src/assets/img"),
        file: resolve("src/assets/file")
      }
    }
  }
};
